package com.baidumap.administrator.happystudy.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.baidumap.administrator.happystudy.R;

/**
 * author: C on 2017/3/21.
 * 展示滑动图片
 */
public class BannarAdapter extends PagerAdapter{

    private Context mContext;
    private int[] pics = new int[] {
            R.mipmap.lunbotu,
            R.mipmap.lunbotu,
            R.mipmap.lunbotu
    };

    public BannarAdapter(Context context) {
        mContext = context;
    }

    @Override
    public int getCount() {
        return pics.length;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        ImageView imageView = new ImageView(mContext);
        imageView.setImageResource(pics[position]);
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        container.addView(imageView);
        return imageView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }
}
